import React from 'react';
import ReactDOM from 'react-dom';
import './index.less';
import App from './App';
import Login from './Login'
import * as serviceWorker from './serviceWorker';
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import { Provider } from 'react-redux'

import { BrowserRouter, Route,Switch ,Redirect} from 'react-router-dom'
import reducers from './reducer'
import AuthRoute from "./authroute";

const store = createStore(reducers, compose(
    applyMiddleware(thunk),
    window.devToolsExtension?window.devToolsExtension():f=>f
))

ReactDOM.render(
    (<Provider store={store}>
        <BrowserRouter>
            <div>
                <AuthRoute/>
                <Switch>
                    <Route exec path='/login' component={Login}></Route>
                    <Route exec component={App}></Route>
                </Switch>
            </div>
        </BrowserRouter>
    </Provider>)
    , document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();


